//app.js
App({
  globalData: {
    openid:'',
  },
  onLaunch: function () {
    
    if (!wx.cloud) {
      console.error('请使用 2.2.3 或以上的基础库以使用云能力')
    } else {
      wx.cloud.init({
        traceUser: true,
      })
    }
  },
  getOpenid: function () {

    var that = this;
    return new Promise(function (resolve, reject) {
    
      wx.cloud.callFunction({
        name: 'login',
        data: {},
        success: res => {
          console.log('[云函数] [login] user openid: ', res.result.userInfo.openId)
          that.globalData.openid = res.result.userInfo.openId;
          resolve(res);
        },
        fail: err => {
          console.error('[云函数] [login] 调用失败', err)
          reject(err)
          // wx.navigateTo({
          //   url: '../deployFunctions/deployFunctions',
          // })
        }
      })
    })

  },
})
